package com.itheima.health.controller;

import com.itheima.health.dto.SetmealDTO;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.service.SetmealService;
import com.itheima.health.utils.aliyunoss.AliyunUtils;
import com.itheima.health.utils.poi.POIUtils;
import com.itheima.health.utils.redis.RedisUtil;
import com.itheima.health.utils.resources.RedisConstant;
import com.itheima.health.utils.resources.UploadUtils;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("ordersetting")
public class OrderSettingController {

    @Reference
    OrderSettingService orderSettingService;

    @RequestMapping("importOrderSettings")
    public Result importOrderSettings(@RequestParam("excelFile")MultipartFile file){
        List<String[]> listStrings = POIUtils.readExcel(file);
        orderSettingService.importOrderSettings(listStrings);
        return new Result(true);
    }

    @GetMapping("findSettingData/{year}/{month}")
    public Result findSettingData(@PathVariable int year,@PathVariable int month){
        return new Result(orderSettingService.findSettingData(year,month));
    }

    @PutMapping("updateNumberByOrderDate/{number}/{orderdate}")
    public Result updateNumberByOrderDate(@PathVariable("number") int number,@PathVariable("orderdate") String orderdate){

        return new Result(orderSettingService.updateNumberByOrderDate(number,orderdate));
    }}
